<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BaseUrines {

	protected $m_intId;
	protected $m_intPatientId;
	protected $m_intCasePaperId;
	protected $m_intDoctorId;
	protected $m_intDepartmentId;
	protected $m_intDiagnosisId;
	protected $m_intChargeId;
	protected $m_strColor;
	protected $m_strDeposit;
	protected $m_strReaction;
	protected $m_strAlbumin;
	protected $m_strSugar;
	protected $m_strScetene;
	protected $m_strDiaceticAcid;
	protected $m_strBileSacts;
	protected $m_strBileDigments;
	protected $m_strPusCells;
	protected $m_strPbc;
	protected $m_strCasts;
	protected $m_strCrystals;
	protected $m_strCells;
	protected $m_strMicroOrganisms;
	protected $m_strRemarks;
	protected $m_intDocumentAttachmentId;
	protected $m_strAttachmentPath;
	protected $m_strCreatedOn;
	protected $m_intCreatedBy;
	protected $m_strUpdatedOn;
	protected $m_intUpdatedBy;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getPatientId(){
		return $this->m_intPatientId;
	}

	public function getCasePaperId(){
		return $this->m_intCasePaperId;
	}

	public function getDoctorId(){
		return $this->m_intDoctorId;
	}

	public function getDepartmentId(){
		return $this->m_intDepartmentId;
	}

	public function getDiagnosisId(){
		return $this->m_intDiagnosisId;
	}

	public function getChargeId(){
		return $this->m_intChargeId;
	}

	public function getColor(){
		return $this->m_strColor;
	}

	public function getDeposit(){
		return $this->m_strDeposit;
	}

	public function getReaction(){
		return $this->m_strReaction;
	}

	public function getAlbumin(){
		return $this->m_strAlbumin;
	}

	public function getSugar(){
		return $this->m_strSugar;
	}

	public function getScetene(){
		return $this->m_strScetene;
	}

	public function getDiaceticAcid(){
		return $this->m_strDiaceticAcid;
	}

	public function getBileSacts(){
		return $this->m_strBileSacts;
	}

	public function getBileDigments(){
		return $this->m_strBileDigments;
	}

	public function getPusCells(){
		return $this->m_strPusCells;
	}

	public function getPbc(){
		return $this->m_strPbc;
	}

	public function getCasts(){
		return $this->m_strCasts;
	}

	public function getCrystals(){
		return $this->m_strCrystals;
	}

	public function getCells(){
		return $this->m_strCells;
	}

	public function getMicroOrganisms(){
		return $this->m_strMicroOrganisms;
	}

	public function getRemarks(){
		return $this->m_strRemarks;
	}

	public function getDocumentAttachmentId(){
		return $this->m_intDocumentAttachmentId;
	}

	public function getAttachmentPath(){
		return $this->m_strAttachmentPath;
	}

	public function getCreatedOn(){
		return $this->m_strCreatedOn;
	}

	public function getCreatedBy(){
		return $this->m_intCreatedBy;
	}

	public function getUpdatedOn(){
		return $this->m_strUpdatedOn;
	}

	public function getUpdatedBy(){
		return $this->m_intUpdatedBy;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setPatientId( $PatientId ){
		$this->m_intPatientId = $PatientId;
	}

	public function setCasePaperId( $CasePaperId ){
		$this->m_intCasePaperId = $CasePaperId;
	}

	public function setDoctorId( $DoctorId ){
		$this->m_intDoctorId = $DoctorId;
	}

	public function setDepartmentId( $DepartmentId ){
		$this->m_intDepartmentId = $DepartmentId;
	}

	public function setDiagnosisId( $DiagnosisId ){
		$this->m_intDiagnosisId = $DiagnosisId;
	}

	public function setChargeId( $ChargeId ){
		$this->m_intChargeId = $ChargeId;
	}

	public function setColor( $Color ){
		$this->m_strColor = $Color;
	}

	public function setDeposit( $Deposit ){
		$this->m_strDeposit = $Deposit;
	}

	public function setReaction( $Reaction ){
		$this->m_strReaction = $Reaction;
	}

	public function setAlbumin( $Albumin ){
		$this->m_strAlbumin = $Albumin;
	}

	public function setSugar( $Sugar ){
		$this->m_strSugar = $Sugar;
	}

	public function setScetene( $Scetene ){
		$this->m_strScetene = $Scetene;
	}

	public function setDiaceticAcid( $DiaceticAcid ){
		$this->m_strDiaceticAcid = $DiaceticAcid;
	}

	public function setBileSacts( $BileSacts ){
		$this->m_strBileSacts = $BileSacts;
	}

	public function setBileDigments( $BileDigments ){
		$this->m_strBileDigments = $BileDigments;
	}

	public function setPusCells( $PusCells ){
		$this->m_strPusCells = $PusCells;
	}

	public function setPbc( $Pbc ){
		$this->m_strPbc = $Pbc;
	}

	public function setCasts( $Casts ){
		$this->m_strCasts = $Casts;
	}

	public function setCrystals( $Crystals ){
		$this->m_strCrystals = $Crystals;
	}

	public function setCells( $Cells ){
		$this->m_strCells = $Cells;
	}

	public function setMicroOrganisms( $MicroOrganisms ){
		$this->m_strMicroOrganisms = $MicroOrganisms;
	}

	public function setRemarks( $Remarks ){
		$this->m_strRemarks = $Remarks;
	}

	public function setDocumentAttachmentId( $DocumentAttachmentId ){
		$this->m_intDocumentAttachmentId = $DocumentAttachmentId;
	}

	public function setAttachmentPath( $AttachmentPath ){
		$this->m_strAttachmentPath = $AttachmentPath;
	}

	public function setCreatedOn( $CreatedOn ){
		$this->m_strCreatedOn = $CreatedOn;
	}

	public function setCreatedBy( $CreatedBy ){
		$this->m_intCreatedBy = $CreatedBy;
	}

	public function setUpdatedOn( $UpdatedOn ){
		$this->m_strUpdatedOn = $UpdatedOn;
	}

	public function setUpdatedBy( $UpdatedBy ){
		$this->m_intUpdatedBy = $UpdatedBy;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into URINES (patient_id, case_paper_id, doctor_id, department_id, diagnosis_id, charge_id, color, deposit, reaction, albumin, sugar, scetene, diacetic_acid, bile_sacts, Bile_digments, pus_cells, pbc, casts, crystals, cells, micro_organisms, remarks, document_attachment_id, attachment_path, created_on, created_by, updated_on, updated_by) values (" . $this->getPatientId() . ", " . $this->getCasePaperId() . ", " . $this->getDoctorId() . ", " . $this->getDepartmentId() . ", " . $this->getDiagnosisId() . ", " . $this->getChargeId() . ", '" . $this->getColor() . "', '" . $this->getDeposit() . "', '" . $this->getReaction() . "', '" . $this->getAlbumin() . "', '" . $this->getSugar() . "', '" . $this->getScetene() . "', '" . $this->getDiaceticAcid() . "', '" . $this->getBileSacts() . "', '" . $this->getBileDigments() . "', '" . $this->getPusCells() . "', '" . $this->getPbc() . "', '" . $this->getCasts() . "', '" . $this->getCrystals() . "', '" . $this->getCells() . "', '" . $this->getMicroOrganisms() . "', '" . $this->getRemarks() . "', " . $this->getDocumentAttachmentId() . ", '" . $this->getAttachmentPath() . "', now() , " . $this->getCreatedBy() . ", NULL , " . $this->getUpdatedBy() . ")");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE URINES set  patient_id= " . $this->getPatientId() . ", case_paper_id= " . $this->getCasePaperId() . ", doctor_id= " . $this->getDoctorId() . ", department_id= " . $this->getDepartmentId() . ", diagnosis_id= " . $this->getDiagnosisId() . ", charge_id= " . $this->getChargeId() . ", color= '" . $this->getColor() . "', deposit= '" . $this->getDeposit() . "', reaction= '" . $this->getReaction() . "', albumin= '" . $this->getAlbumin() . "', sugar= '" . $this->getSugar() . "', scetene= '" . $this->getScetene() . "', diacetic_acid= '" . $this->getDiaceticAcid() . "', bile_sacts= '" . $this->getBileSacts() . "', Bile_digments= '" . $this->getBileDigments() . "', pus_cells= '" . $this->getPusCells() . "', pbc= '" . $this->getPbc() . "', casts= '" . $this->getCasts() . "', crystals= '" . $this->getCrystals() . "', cells= '" . $this->getCells() . "', micro_organisms= '" . $this->getMicroOrganisms() . "', remarks= '" . $this->getRemarks() . "', document_attachment_id= " . $this->getDocumentAttachmentId() . ", attachment_path= '" . $this->getAttachmentPath() . "', created_by= " . $this->getCreatedBy() . ",updated_on = now() ,  updated_by= " . $this->getUpdatedBy() . " where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM urines WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'urines'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}